Dynomotion

Group: DynoMotion Message: 5822 From: gracemckay Date: 10/19/2012
Subject: Control from external switches
Hi Tom,

Me again. I am wondering if I can get my start stop rewind programs to actuate from hardware switches. These are basically jog commands on Axis 0. As and example, this is the stop routine:

#include "KMotionDef.h"
#define FLASHBIT 0 //Bit 44 corresponds to Pin5 JP7
#define CAMERABIT 1 //Bit 45 corresponds to Pin6 JP7

main()
{

Jog(0,0000); // stop moving
Jog(1,0000); // stop moving
Jog(2,0000); // stop moving
Jog(3,0000); // stop moving

SetBit(FLASHBIT); //turns led light on
SetBit(CAMERABIT); //triggers camera capture
//ClearBit(CAMERABIT); //clears camera capture
}

The start executes a jog(0,800) the rewind is on Axis 3 jog(3,4000)

Can these all be integrated into a single thread that listens to a set of bits that can be set with external switches? How would the switches be wired? This is how I am visualizing it, but my guess is I may be close, but that you will have a much better suggestion. What do you think?

Grace
Group: DynoMotion Message: 5824 From: Tom Kerekes Date: 10/19/2012
Subject: Re: Control from external switches
Hi Grace,
 
There are a number of ways to wire up switches.  One simple way is to use the first 8 IO on KFLOP JP4 or JP6 that have pull down resistors and simply switch the pin to +3.3V.
 
There is an example helper function called "Debounce" in Mach3_CL_PMDX.c that will help debounce your switches and tell you when the switch is first depressed (1), released (0), or no change (-1).
 
Regards
TK
 

Group: DynoMotion Message: 5829 From: gracemckay Date: 10/20/2012
Subject: Re: Control from external switches
Thanks Tom, I now have the switches wired up to JP4 as you suggested. I have some code that actually kind of works. But it needs some smarts put in to it. Here is an example for the play and stop switches:

#include "KMotionDef.h"

#define PLAYBIT 16
#define PLAYHOLDBIT 48

#define STOPBIT 17
#define STOPHOLDBIT 49

main()
{

int play = ReadBit(PLAYBIT);
int playhold = ReadBit(PLAYHOLDBIT);
int stop = ReadBit (STOPBIT);
int stophold = ReadBit (STOPHOLDBIT);


if (play == 1) // PLAY routine
{
ClearBit(STOPHOLDBIT);
ClearBit(FASTPLAYHOLDBIT);
ClearBit(REVERSEPLAYHOLDBIT);
ClearBit(FASTREVERSEPLAYHOLDBIT);
SetBit(PLAYHOLDBIT);
Jog(0,200);
}

if (playhold == 1) //PLAY HOLD
{
ClearBit(STOPHOLDBIT);
ClearBit(FASTPLAYHOLDBIT);
ClearBit(REVERSEPLAYHOLDBIT);
ClearBit(FASTREVERSEPLAYHOLDBIT);
Jog(0,200);
}


if (stop == 1) //STOP Routine
{
ClearBit(PLAYHOLDBIT);
ClearBit(FASTPLAYHOLDBIT);
ClearBit(REVERSEPLAYHOLDBIT);
ClearBit(FASTREVERSEPLAYHOLDBIT);
SetBit(STOPHOLDBIT);
Jog(0,000);
}

if (stophold == 1) //STOP HOLD
{
ClearBit(PLAYHOLDBIT);
ClearBit(FASTPLAYHOLDBIT);
ClearBit(REVERSEPLAYHOLDBIT);
ClearBit(FASTREVERSEPLAYHOLDBIT);
Jog(0,000);
}
}

There are actually 5 switches, but you get the idea. But this seems like brute force, with no elegance. And it needs a loop of some kind to keep it looking for input.

Can you help fill in the details? What loop code would work and is there a better way to do this?

Grace





--- In DynoMotion@yahoogroups.com, Tom Kerekes <tk@...> wrote:
>
> Hi Grace,
>  
> There are a number of ways to wire up switches.  One simple way is to use the first 8 IO on KFLOP JP4 or JP6 that have pull down resistors and simply switch the pin to +3.3V.
>  There is an example helper function called "Debounce" in Mach3_CL_PMDX.c that will help debounce your switches and tell you when the switch is first depressed (1), released (0), or no change (-1).
>  
> Regards
> TK
>  
>
> From: gracemckay <grace@...>
> To: DynoMotion@yahoogroups.com
> Sent: Friday, October 19, 2012 11:24 AM
> Subject: [DynoMotion] Control from external switches
>
>  
> Hi Tom,
>
> Me again. I am wondering if I can get my start stop rewind programs to actuate from hardware switches. These are basically jog commands on Axis 0. As and example, this is the stop routine:
>
> #include "KMotionDef.h"
> #define FLASHBIT 0 //Bit 44 corresponds to Pin5 JP7
> #define CAMERABIT 1 //Bit 45 corresponds to Pin6 JP7
>
> main()
> {
>
> Jog(0,0000); // stop moving
> Jog(1,0000); // stop moving
> Jog(2,0000); // stop moving
> Jog(3,0000); // stop moving
>
> SetBit(FLASHBIT); //turns led light on
> SetBit(CAMERABIT); //triggers camera capture
> //ClearBit(CAMERABIT); //clears camera capture
> }
>
> The start executes a jog(0,800) the rewind is on Axis 3 jog(3,4000)
>
> Can these all be integrated into a single thread that listens to a set of bits that can be set with external switches? How would the switches be wired? This is how I am visualizing it, but my guess is I may be close, but that you will have a much better suggestion. What do you think?
>
> Grace
>
Group: DynoMotion Message: 5832 From: Tom Kerekes Date: 10/21/2012
Subject: Re: Control from external switches
Hi Grace,
 
Your program is treating IO bits as at first as inputs and then as outputs which doesn't make sense.  I assume they are really inputs.  So the code you have reading them would be correct.  Remove the code where they are set and cleared.  It isn't possible to command a pushbutton switch input to change. 
 
As you describe it also doesn't loop forever watching the switches.  It is also missing code that will only do something once when a switch changes rather than constantly when a switch is pushed.  It also doesn't have any switch debounce or noise filtering.
 
I'd like you to at least give it a try so you can learn how to make future changes.  Here is the basic process:
 
#1 copy in the Debounce function (see previous email).  Place it at the end of the file.  But add in the Debounce declaration towards the beginning so the compiler knows about it early on.  See how it is done in the example.
 
#2 a few memory variables need to be declared for each switch toward the begging of the program.  The debounce function needs these to keep track of things regarding the switch.  previous state, previous valid state, and for how long.  See the example below.  Replace the letter "f" with a letter or word that corresponds to the switch name.  Repeat for every switch.
 
int flast=0,flastsolid=-1,fcount=0;
 
so for example your "play" button might be:
 
int playlast=0,playlastsolid=-1,playcount=0;
 
#3 Then in the core of the program we can make calls to the function passing the signal of interest and the variables that it will update for that switch.  The result that it returns will tell us whether we should take action because the button was just pushed down (result==1)
 
 
  result = Debounce(play,&playcount,&playlast,&playlastsolid);
  if (result == 1)
  {
        Jog(0,200);
  }
  
 
#4 Add a forever loop around the core code that monitors the switches.
 
for (;;)
{
     //  put all the code that should be repeated here between the curly brackets
}
 
 
Try and see if you do those steps and post the results for us to check.  BTW your posted code doesn't have some things like FASTREVERSEPLAYHOLDBIT defined anywhere so I can't understand how it could compile.
 
Regards
TK 
 
 
 
 
 
 
Group: DynoMotion Message: 5856 From: gracemckay Date: 10/23/2012
Subject: Re: Control from external switches
Hi Tom, thanks for your patience. Here is the code I came up with based on your notes:

#include "KMotionDef.h"

#define PLAYBIT 16
#define STOPBIT 17
#define FASTPLAYBIT 18
#define REVERSEPLAYBIT 19
#define FASTREVERSEPLAYBIT 20

int playlast=0,playlastsolid=-1,playcount=0;
int stoplast=0,stoplastsolid=-1,stopcount=0;
int fastplaylast=0,fastplaylastsolid=-1,fastplaycount=0;
int reverseplaylast=0,reverseplaylastsolid=-1,reverseplaycount=0;
int fastreverseplaylast=0,fastreverseplaylastsolid=-1, fastreverseplaycount=0;

int Debounce(int n, int *cnt, int *last, int *lastsolid);

main()
{
int play = ReadBit(PLAYBIT);
int stop = ReadBit (STOPBIT);
int fastplay = ReadBit(FASTPLAYBIT);
int reverseplay = ReadBit(REVERSEPLAYBIT);
int fastreverseplay = ReadBit(FASTREVERSEPLAYBIT);


for (;;)
{

result = Debounce(play,&playcount,&playlast,&playlastsolid);
if (result == 1)
{
Jog(0,200);
}

if (play == 1) // PLAY routine
{
Jog(0,800);
}

if (stop == 1) //STOP Routine
{
Jog(0,000);
}

if (fastplay == 1) //FAST PLAY Routine
{
Jog(0,1200);
}

if (fastreverseplay == 1) //FAST REVERSE PLAY Routine
{
Jog(0,-1200);
}

if (reverseplay == 1) //REVERSE PLAY Routine
{
Jog(0,-200);
}

WaitNextTimeSlice();
}

}


// Debounce a bit
//
// return 1 one time when first debounced high
// return 0 one time when first debounced low
// return -1 otherwise
#define DBTIME 300

int Debounce(int n, int *cnt, int *last, int *lastsolid)
{
int v = -1;

if (n == *last) // same as last time?
{
if (*cnt == DBTIME-1)
{
if (n != *lastsolid)
{
v = *lastsolid = n; // return debounced value
}
}
if (*cnt < DBTIME) (*cnt)++;
}
else
{
*cnt = 0; // reset count
}
*last = n;
return v;
}


This code doesn't compile, so I know I have done something wrong, but haven't figured it out yet. It stopped compiling when I dropped in the result code:

result = Debounce(play,&playcount,&playlast,&playlastsolid);
if (result == 1)
{
Jog(0,200);
}


Does each switch get it's own debounce code, or are the wildcards supposed to take care of it for all switches?

Grace





--- In DynoMotion@yahoogroups.com, Tom Kerekes <tk@...> wrote:
>
> Hi Grace,
>  
> Your program is treating IO bits as at first as inputs and then as outputs which doesn't make sense.  I assume they are really inputs.  So the code you have reading them would be correct.  Remove the code where they are set and cleared.  It isn't possible to command a pushbutton switch input to change. 
>  
> As you describe it also doesn't loop forever watching the switches.  It is also missing code that will only do something once when a switch changes rather than constantly when a switch is pushed.  It also doesn't have any switch debounce or noise filtering.
>  
> I'd like you to at least give it a try so you can learn how to make future changes.  Here is the basic process:
>  
> #1 copy in the Debounce function (see previous email).  Place it at the end of the file.  But add in the Debounce declaration towards the beginning so the compiler knows about it early on.  See how it is done in the example.
>  
> #2 a few memory variables need to be declared for each switch toward the begging of the program.  The debounce function needs these to keep track of things regarding the switch.  previous state, previous valid state, and for how long.  See the example below.  Replace the letter "f" with a letter or word that corresponds to the switch name.  Repeat for every switch.
>  
> int flast=0,flastsolid=-1,fcount=0;
>
>  
> so for example your "play" button might be:
>  
> int playlast=0,playlastsolid=-1,playcount=0;
>  
> #3 Then in the core of the program we can make calls to the function passing the signal of interest and the variables that it will update for that switch.  The result that it returns will tell us whether we should take action because the button was just pushed down (result==1)
>  
>  
>   result = Debounce(play,&playcount,&playlast,&playlastsolid);
>   if (result == 1)
>   {
>         Jog(0,200);
>   }
>   
>  
> #4 Add a forever loop around the core code that monitors the switches.
>  
> for (;;)
> {
>      //  put all the code that should be repeated here between the curly brackets
> }
>  
>  
> Try and see if you do those steps and post the results for us to check.  BTW your posted code doesn't have some things like FASTREVERSEPLAYHOLDBIT defined anywhere so I can't understand how it could compile.
>  
> Regards
> TK 
>  
>  
>  
>  
>  
>  
> From: gracemckay <grace@...>
> To: DynoMotion@yahoogroups.com
> Sent: Saturday, October 20, 2012 1:28 PM
> Subject: [DynoMotion] Re: Control from external switches
>
>  
> Thanks Tom, I now have the switches wired up to JP4 as you suggested. I have some code that actually kind of works. But it needs some smarts put in to it. Here is an example for the play and stop switches:
>
> #include "KMotionDef.h"
>
> #define PLAYBIT 16
> #define PLAYHOLDBIT 48
>
> #define STOPBIT 17
> #define STOPHOLDBIT 49
>
> main()
> {
>
> int play = ReadBit(PLAYBIT);
> int playhold = ReadBit(PLAYHOLDBIT);
> int stop = ReadBit (STOPBIT);
> int stophold = ReadBit (STOPHOLDBIT);
>
>
> if (play == 1) // PLAY routine
> {
> ClearBit(STOPHOLDBIT);
> ClearBit(FASTPLAYHOLDBIT);
> ClearBit(REVERSEPLAYHOLDBIT);
> ClearBit(FASTREVERSEPLAYHOLDBIT);
> SetBit(PLAYHOLDBIT);
> Jog(0,200);
> }
>
> if (playhold == 1) //PLAY HOLD
> {
> ClearBit(STOPHOLDBIT);
> ClearBit(FASTPLAYHOLDBIT);
> ClearBit(REVERSEPLAYHOLDBIT);
> ClearBit(FASTREVERSEPLAYHOLDBIT);
> Jog(0,200);
> }
>
>
> if (stop == 1) //STOP Routine
> {
> ClearBit(PLAYHOLDBIT);
> ClearBit(FASTPLAYHOLDBIT);
> ClearBit(REVERSEPLAYHOLDBIT);
> ClearBit(FASTREVERSEPLAYHOLDBIT);
> SetBit(STOPHOLDBIT);
> Jog(0,000);
> }
>
> if (stophold == 1) //STOP HOLD
> {
> ClearBit(PLAYHOLDBIT);
> ClearBit(FASTPLAYHOLDBIT);
> ClearBit(REVERSEPLAYHOLDBIT);
> ClearBit(FASTREVERSEPLAYHOLDBIT);
> Jog(0,000);
> }
> }
>
> There are actually 5 switches, but you get the idea. But this seems like brute force, with no elegance. And it needs a loop of some kind to keep it looking for input.
>
> Can you help fill in the details? What loop code would work and is there a better way to do this?
>
> Grace
>
> --- In mailto:DynoMotion%40yahoogroups.com, Tom Kerekes <tk@> wrote:
> >
> > Hi Grace,
> >  
> > There are a number of ways to wire up switches.  One simple way is to use the first 8 IO on KFLOP JP4 or JP6 that have pull down resistors and simply switch the pin to +3.3V.
> >  There is an example helper function called "Debounce" in Mach3_CL_PMDX.c that will help debounce your switches and tell you when the switch is first depressed (1), released (0), or no change (-1).
> >  
> > Regards
> > TK
> >  
> >
> > From: gracemckay <grace@>
> > To: mailto:DynoMotion%40yahoogroups.com
> > Sent: Friday, October 19, 2012 11:24 AM
> > Subject: [DynoMotion] Control from external switches
> >
> >  
> > Hi Tom,
> >
> > Me again. I am wondering if I can get my start stop rewind programs to actuate from hardware switches. These are basically jog commands on Axis 0. As and example, this is the stop routine:
> >
> > #include "KMotionDef.h"
> > #define FLASHBIT 0 //Bit 44 corresponds to Pin5 JP7
> > #define CAMERABIT 1 //Bit 45 corresponds to Pin6 JP7
> >
> > main()
> > {
> >
> > Jog(0,0000); // stop moving
> > Jog(1,0000); // stop moving
> > Jog(2,0000); // stop moving
> > Jog(3,0000); // stop moving
> >
> > SetBit(FLASHBIT); //turns led light on
> > SetBit(CAMERABIT); //triggers camera capture
> > //ClearBit(CAMERABIT); //clears camera capture
> > }
> >
> > The start executes a jog(0,800) the rewind is on Axis 3 jog(3,4000)
> >
> > Can these all be integrated into a single thread that listens to a set of bits that can be set with external switches? How would the switches be wired? This is how I am visualizing it, but my guess is I may be close, but that you will have a much better suggestion. What do you think?
> >
> > Grace
> >
>
Group: DynoMotion Message: 5857 From: Tom Kerekes Date: 10/23/2012
Subject: Re: Control from external switches
Hi Grace.
 
Excellent work.  You only forgot to declare the variable "result" which is why you get the error message:
 
'result' undeclared
 
Declare result as an integer variable up near the beginning of the block of code where it is used by adding the line below
 
int result;
 
Actually I see one other mistake.  All the ReadBit commands are before the "for" loop.  This would only read the switches once and then they would never change while in the loop.  We want to repeatedly read the switches so later when the Operator pushes the button we detect the change.  So move:
 
 
Oh, and yes, each switch must make its own call to Debounce() passing the corresponding variables and the "if" should check the result from the Debounce call not the switch.
 
Hang in there you almost got it.
 
Regards
TK 
 

Group: DynoMotion Message: 5871 From: gracemckay Date: 10/24/2012
Subject: Re: Control from external switches
Wow, it's really great! It actually works! Here is the code I came up with based on the last email:

#include "KMotionDef.h"

#define PLAYBIT 16 //JP4 PIN 4
#define STOPBIT 17 //JP4 PIN 5
#define FASTPLAYBIT 18 //JP4 PIN 6
#define REVERSEPLAYBIT 19 //JP4 PIN 10
#define FASTREVERSEPLAYBIT 20 //JP4 PIN 11
#define FASTREVERSEPLAYBIT 21 //JP4 PIN 12

int playlast=0,playlastsolid=-1,playcount=0;
int stoplast=0,stoplastsolid=-1,stopcount=0;
int fastplaylast=0,fastplaylastsolid=-1,fastplaycount=0;
int reverseplaylast=0,reverseplaylastsolid=-1,reverseplaycount=0;
int fastreverseplaylast=0,fastreverseplaylastsolid=-1,fastreverseplaycount=0;

int Debounce(int n, int *cnt, int *last, int *lastsolid);

main()
{


for (;;)
{
int play = ReadBit(PLAYBIT);
int stop = ReadBit (STOPBIT);
int fastplay = ReadBit(FASTPLAYBIT);
int reverseplay = ReadBit(REVERSEPLAYBIT);
int fastreverseplay = ReadBit(FASTREVERSEPLAYBIT);
int result;


result = Debounce(play,&playcount,&playlast,&playlastsolid);
result = Debounce(stop,&stopcount,&stoplast,&stoplastsolid);
result = Debounce(fastplay,&fastplaycount,&fastplaylast,&fastplaylastsolid);
result = Debounce(reverseplay,&reverseplaycount,&reverseplaylast,&reverseplaylastsolid);
result = Debounce(fastreverseplay,&fastreverseplaycount,&fastreverseplaylast,&fastreverseplaylastsolid);

if (result == 1)
{
Jog(0,800);
}

if (play == 1) // PLAY routine
{
Jog(0,800);
}

if (stop == 1) //STOP Routine
{
Jog(0,000);
}

if (fastplay == 1) //FAST PLAY Routine
{
Jog(0,1200);
}

if (fastreverseplay == 1) //FAST REVERSE PLAY Routine
{
Jog(0,-1200);
}

if (reverseplay == 1) //REVERSE PLAY Routine
{
Jog(0,-200);
}

WaitNextTimeSlice();
}

}


// Debounce a bit
//
// return 1 one time when first debounced high
// return 0 one time when first debounced low
// return -1 otherwise
#define DBTIME 300

int Debounce(int n, int *cnt, int *last, int *lastsolid)
{
int v = -1;

if (n == *last) // same as last time?
{
if (*cnt == DBTIME-1)
{
if (n != *lastsolid)
{
v = *lastsolid = n; // return debounced value
}
}
if (*cnt < DBTIME) (*cnt)++;
}
else
{
*cnt = 0; // reset count
}
*last = n;
return v;
}


Thanks Tom, for all your help and your patience in walking me through this. I am slowly learning something, it seems. My humble thanks again.

Grace



--- In DynoMotion@yahoogroups.com, Tom Kerekes <tk@...> wrote:
>
> Hi Grace.
>  
> Excellent work.  You only forgot to declare the variable "result" which is why you get the error message:
>  
> 'result' undeclared
>  
> Declare result as an integer variable up near the beginning of the block of code where it is used by adding the line below
>  
> int result;
>  
> Actually I see one other mistake.  All the ReadBit commands are before the "for" loop.  This would only read the switches once and then they would never change while in the loop.  We want to repeatedly read the switches so later when the Operator pushes the button we detect the change.  So move:
>  
>  
> Oh, and yes, each switch must make its own call to Debounce() passing the corresponding variables and the "if" should check the result from the Debounce call not the switch.
>  
> Hang in there you almost got it.
>  
> Regards
> TK 
>  
>
> From: gracemckay <grace@...>
> To: DynoMotion@yahoogroups.com
> Sent: Tuesday, October 23, 2012 9:20 AM
> Subject: [DynoMotion] Re: Control from external switches
>
>  
> Hi Tom, thanks for your patience. Here is the code I came up with based on your notes:
>
> #include "KMotionDef.h"
>
> #define PLAYBIT 16
> #define STOPBIT 17
> #define FASTPLAYBIT 18
> #define REVERSEPLAYBIT 19
> #define FASTREVERSEPLAYBIT 20
>
> int playlast=0,playlastsolid=-1,playcount=0;
> int stoplast=0,stoplastsolid=-1,stopcount=0;
> int fastplaylast=0,fastplaylastsolid=-1,fastplaycount=0;
> int reverseplaylast=0,reverseplaylastsolid=-1,reverseplaycount=0;
> int fastreverseplaylast=0,fastreverseplaylastsolid=-1, fastreverseplaycount=0;
>
> int Debounce(int n, int *cnt, int *last, int *lastsolid);
>
> main()
> {
> int play = ReadBit(PLAYBIT);
> int stop = ReadBit (STOPBIT);
> int fastplay = ReadBit(FASTPLAYBIT);
> int reverseplay = ReadBit(REVERSEPLAYBIT);
> int fastreverseplay = ReadBit(FASTREVERSEPLAYBIT);
>
>
> for (;;)
> {
>
> result = Debounce(play,&playcount,&playlast,&playlastsolid);
> if (result == 1)
> {
> Jog(0,200);
> }
>
> if (play == 1) // PLAY routine
> {
> Jog(0,800);
> }
>
> if (stop == 1) //STOP Routine
> {
> Jog(0,000);
> }
>
> if (fastplay == 1) //FAST PLAY Routine
> {
> Jog(0,1200);
> }
>
> if (fastreverseplay == 1) //FAST REVERSE PLAY Routine
> {
> Jog(0,-1200);
> }
>
> if (reverseplay == 1) //REVERSE PLAY Routine
> {
> Jog(0,-200);
> }
>
> WaitNextTimeSlice();
> }
>
> }
>
> // Debounce a bit
> //
> // return 1 one time when first debounced high
> // return 0 one time when first debounced low
> // return -1 otherwise
> #define DBTIME 300
>
> int Debounce(int n, int *cnt, int *last, int *lastsolid)
> {
> int v = -1;
>
> if (n == *last) // same as last time?
> {
> if (*cnt == DBTIME-1)
> {
> if (n != *lastsolid)
> {
> v = *lastsolid = n; // return debounced value
> }
> }
> if (*cnt < DBTIME) (*cnt)++;
> }
> else
> {
> *cnt = 0; // reset count
> }
> *last = n;
> return v;
> }
>
> This code doesn't compile, so I know I have done something wrong, but haven't figured it out yet. It stopped compiling when I dropped in the result code:
>
> result = Debounce(play,&playcount,&playlast,&playlastsolid);
> if (result == 1)
> {
> Jog(0,200);
> }
>
> Does each switch get it's own debounce code, or are the wildcards supposed to take care of it for all switches?
>
> Grace
>
> --- In mailto:DynoMotion%40yahoogroups.com, Tom Kerekes <tk@> wrote:
> >
> > Hi Grace,
> >  
> > Your program is treating IO bits as at first as inputs and then as outputs which doesn't make sense.  I assume they are really inputs.  So the code you have reading them would be correct.  Remove the code where they are set and cleared.  It isn't possible to command a pushbutton switch input to change. 
> >  
> > As you describe it also doesn't loop forever watching the switches.  It is also missing code that will only do something once when a switch changes rather than constantly when a switch is pushed.  It also doesn't have any switch debounce or noise filtering.
> >  
> > I'd like you to at least give it a try so you can learn how to make future changes.  Here is the basic process:
> >  
> > #1 copy in the Debounce function (see previous email).  Place it at the end of the file.  But add in the Debounce declaration towards the beginning so the compiler knows about it early on.  See how it is done in the example.
> >  
> > #2 a few memory variables need to be declared for each switch toward the begging of the program.  The debounce function needs these to keep track of things regarding the switch.  previous state, previous valid state, and for how long.  See the example below.  Replace the letter "f" with a letter or word that corresponds to the switch name.  Repeat for every switch.
> >  
> > int flast=0,flastsolid=-1,fcount=0;
> >
> >  
> > so for example your "play" button might be:
> >  
> > int playlast=0,playlastsolid=-1,playcount=0;
> >  
> > #3 Then in the core of the program we can make calls to the function passing the signal of interest and the variables that it will update for that switch.  The result that it returns will tell us whether we should take action because the button was just pushed down (result==1)
> >  
> >  
> >   result = Debounce(play,&playcount,&playlast,&playlastsolid);
> >   if (result == 1)
> >   {
> >         Jog(0,200);
> >   }
> >   
> >  
> > #4 Add a forever loop around the core code that monitors the switches.
> >  
> > for (;;)
> > {
> >      //  put all the code that should be repeated here between the curly brackets
> > }
> >  
> >  
> > Try and see if you do those steps and post the results for us to check.  BTW your posted code doesn't have some things like FASTREVERSEPLAYHOLDBIT defined anywhere so I can't understand how it could compile.
> >  
> > Regards
> > TK 
> >  
> >  
> >  
> >  
> >  
> >  
> > From: gracemckay <grace@>
> > To: mailto:DynoMotion%40yahoogroups.com
> > Sent: Saturday, October 20, 2012 1:28 PM
> > Subject: [DynoMotion] Re: Control from external switches
> >
> >  
> > Thanks Tom, I now have the switches wired up to JP4 as you suggested. I have some code that actually kind of works. But it needs some smarts put in to it. Here is an example for the play and stop switches:
> >
> > #include "KMotionDef.h"
> >
> > #define PLAYBIT 16
> > #define PLAYHOLDBIT 48
> >
> > #define STOPBIT 17
> > #define STOPHOLDBIT 49
> >
> > main()
> > {
> >
> > int play = ReadBit(PLAYBIT);
> > int playhold = ReadBit(PLAYHOLDBIT);
> > int stop = ReadBit (STOPBIT);
> > int stophold = ReadBit (STOPHOLDBIT);
> >
> >
> > if (play == 1) // PLAY routine
> > {
> > ClearBit(STOPHOLDBIT);
> > ClearBit(FASTPLAYHOLDBIT);
> > ClearBit(REVERSEPLAYHOLDBIT);
> > ClearBit(FASTREVERSEPLAYHOLDBIT);
> > SetBit(PLAYHOLDBIT);
> > Jog(0,200);
> > }
> >
> > if (playhold == 1) //PLAY HOLD
> > {
> > ClearBit(STOPHOLDBIT);
> > ClearBit(FASTPLAYHOLDBIT);
> > ClearBit(REVERSEPLAYHOLDBIT);
> > ClearBit(FASTREVERSEPLAYHOLDBIT);
> > Jog(0,200);
> > }
> >
> >
> > if (stop == 1) //STOP Routine
> > {
> > ClearBit(PLAYHOLDBIT);
> > ClearBit(FASTPLAYHOLDBIT);
> > ClearBit(REVERSEPLAYHOLDBIT);
> > ClearBit(FASTREVERSEPLAYHOLDBIT);
> > SetBit(STOPHOLDBIT);
> > Jog(0,000);
> > }
> >
> > if (stophold == 1) //STOP HOLD
> > {
> > ClearBit(PLAYHOLDBIT);
> > ClearBit(FASTPLAYHOLDBIT);
> > ClearBit(REVERSEPLAYHOLDBIT);
> > ClearBit(FASTREVERSEPLAYHOLDBIT);
> > Jog(0,000);
> > }
> > }
> >
> > There are actually 5 switches, but you get the idea. But this seems like brute force, with no elegance. And it needs a loop of some kind to keep it looking for input.
> >
> > Can you help fill in the details? What loop code would work and is there a better way to do this?
> >
> > Grace
> >
> > --- In mailto:DynoMotion%40yahoogroups.com, Tom Kerekes <tk@> wrote:
> > >
> > > Hi Grace,
> > >  
> > > There are a number of ways to wire up switches.  One simple way is to use the first 8 IO on KFLOP JP4 or JP6 that have pull down resistors and simply switch the pin to +3.3V.
> > >  There is an example helper function called "Debounce" in Mach3_CL_PMDX.c that will help debounce your switches and tell you when the switch is first depressed (1), released (0), or no change (-1).
> > >  
> > > Regards
> > > TK
> > >  
> > >
> > > From: gracemckay <grace@>
> > > To: mailto:DynoMotion%40yahoogroups.com
> > > Sent: Friday, October 19, 2012 11:24 AM
> > > Subject: [DynoMotion] Control from external switches
> > >
> > >  
> > > Hi Tom,
> > >
> > > Me again. I am wondering if I can get my start stop rewind programs to actuate from hardware switches. These are basically jog commands on Axis 0. As and example, this is the stop routine:
> > >
> > > #include "KMotionDef.h"
> > > #define FLASHBIT 0 //Bit 44 corresponds to Pin5 JP7
> > > #define CAMERABIT 1 //Bit 45 corresponds to Pin6 JP7
> > >
> > > main()
> > > {
> > >
> > > Jog(0,0000); // stop moving
> > > Jog(1,0000); // stop moving
> > > Jog(2,0000); // stop moving
> > > Jog(3,0000); // stop moving
> > >
> > > SetBit(FLASHBIT); //turns led light on
> > > SetBit(CAMERABIT); //triggers camera capture
> > > //ClearBit(CAMERABIT); //clears camera capture
> > > }
> > >
> > > The start executes a jog(0,800) the rewind is on Axis 3 jog(3,4000)
> > >
> > > Can these all be integrated into a single thread that listens to a set of bits that can be set with external switches? How would the switches be wired? This is how I am visualizing it, but my guess is I may be close, but that you will have a much better suggestion. What do you think?
> > >
> > > Grace
> > >
> >
>
Group: DynoMotion Message: 5872 From: Tom Kerekes Date: 10/24/2012
Subject: Re: Control from external switches
Hi Grace,

Well it is good that it works, but the switches are not actually being debounced and detecting a change of state.

The variable "result" can only hold one value at a time.  Storing multiple things into it will overwrite previous values and only the last value will be stored.  For example doing:

result=1;
result=2;
result=3;

In the end will only retain the value of 3.  The first two assignments are a waste of time and have no effect.

instead we might do something like:

result=1;
// use the value of result
result=2;
// use the value of result
result=3;
// use the value of result

Furthermore the "if" conditions are not using the result returned from the debounce function.  They are using the raw reading from the switches.

So let's change the "for" loop to be like this which uses the debounced results:

for (;;)
{
int play = ReadBit(PLAYBIT);
int stop = ReadBit (STOPBIT);
int fastplay = ReadBit(FASTPLAYBIT);
int reverseplay = ReadBit(REVERSEPLAYBIT);
int fastreverseplay = ReadBit(FASTREVERSEPLAYBIT);
int result;


result = Debounce(play,&playcount,&playlast,&playlastsolid);
if (result == 1)
{
Jog(0,800);
}

result = Debounce(stop,&stopcount,&stoplast,&stoplastsolid);
if (result == 1) //STOP Routine

{
Jog(0,000);
}

result = Debounce(fastplay,&fastplaycount,&fastplaylast,&fastplaylastsolid);
if (result == 1) //FAST PLAY Routine

{
Jog(0,1200);
}

result = Debounce(reverseplay,&reverseplaycount,&reverseplaylast,&reverseplaylastsolid);
if (result == 1) //FAST REVERSE PLAY Routine

{
Jog(0,-1200);
}

result = Debounce(fastreverseplay,&fastreverseplaycount,&fastreverseplaylast,&fastreverseplaylastsolid);
if (result == 1) //REVERSE PLAY Routine
{
Jog(0,-200);
}

WaitNextTimeSlice();





TK

Group: DynoMotion Message: 5904 From: gracemckay Date: 10/26/2012
Subject: Re: Control from external switches
OK, thanks. I think I finally see what you are saying. I just tried it and of course your code works. The last version that kind of worked actuated on the release of the switch, this version on the press.

My next challenges are some mechanical changes, and tuning the camera. Thanks for helping so much on this phase. I will fade into the background for a while.

Grace



--- In DynoMotion@yahoogroups.com, Tom Kerekes <tk@...> wrote:
>
> Hi Grace,
>
> Well it is good that it works, but the switches are not actually being debounced and detecting a change of state.
>
> The variable "result" can only hold one value at a time.  Storing multiple things into it will overwrite previous values and only the last value will be stored.  For example doing:
>
> result=1;
> result=2;
> result=3;
>
> In the end will only retain the value of 3.  The first two assignments are a waste of time and have no effect.
>
> instead we might do something like:
>
> result=1;
> // use the value of result
> result=2;
>
> // use the value of result
> result=3;
> // use the value of result
>
>
> Furthermore the "if" conditions are not using the result returned from the debounce function.  They are using the raw reading from the switches.
>
> So let's change the "for" loop to be like this which uses the debounced results:
>
> for (;;)
> {
> int play = ReadBit(PLAYBIT);
> int stop = ReadBit (STOPBIT);
> int fastplay = ReadBit(FASTPLAYBIT);
> int reverseplay = ReadBit(REVERSEPLAYBIT);
> int fastreverseplay = ReadBit(FASTREVERSEPLAYBIT);
> int result;
>
>
> result = Debounce(play,&playcount,&playlast,&playlastsolid);
> if (result == 1)
> {
> Jog(0,800);
> }
>
> result = Debounce(stop,&stopcount,&stoplast,&stoplastsolid);
> if (result == 1) //STOP Routine
> {
> Jog(0,000);
> }
>
> result = Debounce(fastplay,&fastplaycount,&fastplaylast,&fastplaylastsolid);
> if (result == 1) //FAST PLAY Routine
> {
> Jog(0,1200);
> }
>
> result = Debounce(reverseplay,&reverseplaycount,&reverseplaylast,&reverseplaylastsolid);
> if (result == 1) //FAST REVERSE PLAY Routine
> {
> Jog(0,-1200);
> }
>
> result = Debounce(fastreverseplay,&fastreverseplaycount,&fastreverseplaylast,&fastreverseplaylastsolid);
> if (result == 1) //REVERSE PLAY Routine
> {
> Jog(0,-200);
> }
>
> WaitNextTimeSlice();
> } 
>
>
>
>
>
> TK
>
>
> ________________________________
> From: gracemckay <grace@...>
> To: DynoMotion@yahoogroups.com
> Sent: Wednesday, October 24, 2012 11:21 AM
> Subject: [DynoMotion] Re: Control from external switches
>
>
>  
> Wow, it's really great! It actually works! Here is the code I came up with based on the last email:
>
> #include "KMotionDef.h"
>
> #define PLAYBIT 16 //JP4 PIN 4
> #define STOPBIT 17 //JP4 PIN 5
> #define FASTPLAYBIT 18 //JP4 PIN 6
> #define REVERSEPLAYBIT 19 //JP4 PIN 10
> #define FASTREVERSEPLAYBIT 20 //JP4 PIN 11
> #define FASTREVERSEPLAYBIT 21 //JP4 PIN 12
>
> int playlast=0,playlastsolid=-1,playcount=0;
> int stoplast=0,stoplastsolid=-1,stopcount=0;
> int fastplaylast=0,fastplaylastsolid=-1,fastplaycount=0;
> int reverseplaylast=0,reverseplaylastsolid=-1,reverseplaycount=0;
> int fastreverseplaylast=0,fastreverseplaylastsolid=-1,fastreverseplaycount=0;
>
> int Debounce(int n, int *cnt, int *last, int *lastsolid);
>
> main()
> {
>
>
> for (;;)
> {
> int play = ReadBit(PLAYBIT);
> int stop = ReadBit (STOPBIT);
> int fastplay = ReadBit(FASTPLAYBIT);
> int reverseplay = ReadBit(REVERSEPLAYBIT);
> int fastreverseplay = ReadBit(FASTREVERSEPLAYBIT);
> int result;
>
>
> result = Debounce(play,&playcount,&playlast,&playlastsolid);
> result = Debounce(stop,&stopcount,&stoplast,&stoplastsolid);
> result = Debounce(fastplay,&fastplaycount,&fastplaylast,&fastplaylastsolid);
> result = Debounce(reverseplay,&reverseplaycount,&reverseplaylast,&reverseplaylastsolid);
> result = Debounce(fastreverseplay,&fastreverseplaycount,&fastreverseplaylast,&fastreverseplaylastsolid);
>
> if (result == 1)
> {
> Jog(0,800);
> }
>
> if (play == 1) // PLAY routine
> {
> Jog(0,800);
> }
>
> if (stop == 1) //STOP Routine
> {
> Jog(0,000);
> }
>
> if (fastplay == 1) //FAST PLAY Routine
> {
> Jog(0,1200);
> }
>
> if (fastreverseplay == 1) //FAST REVERSE PLAY Routine
> {
> Jog(0,-1200);
> }
>
> if (reverseplay == 1) //REVERSE PLAY Routine
> {
> Jog(0,-200);
> }
>
> WaitNextTimeSlice();
> }
>
> }
>
> // Debounce a bit
> //
> // return 1 one time when first debounced high
> // return 0 one time when first debounced low
> // return -1 otherwise
> #define DBTIME 300
>
> int Debounce(int n, int *cnt, int *last, int *lastsolid)
> {
> int v = -1;
>
> if (n == *last) // same as last time?
> {
> if (*cnt == DBTIME-1)
> {
> if (n != *lastsolid)
> {
> v = *lastsolid = n; // return debounced value
> }
> }
> if (*cnt < DBTIME) (*cnt)++;
> }
> else
> {
> *cnt = 0; // reset count
> }
> *last = n;
> return v;
> }
>
> Thanks Tom, for all your help and your patience in walking me through this. I am slowly learning something, it seems. My humble thanks again.
>
> Grace
>
> --- In DynoMotion@yahoogroups.com, Tom Kerekes <tk@> wrote:
> >
> > Hi Grace.
> >  
> > Excellent work.  You only forgot to declare the variable "result" which is why you get the error message:
> >  
> > 'result' undeclared
> >  
> > Declare result as an integer variable up near the beginning of the block of code where it is used by adding the line below
> >  
> > int result;
> >  
> > Actually I see one other mistake.  All the ReadBit commands are before the "for" loop.  This would only read the switches once and then they would never change while in the loop.  We want to repeatedly read the switches so later when the Operator pushes the button we detect the change.  So move:
> >  
> >  
> > Oh, and yes, each switch must make its own call to Debounce() passing the corresponding variables and the "if" should check the result from the Debounce call not the switch.
> >  
> > Hang in there you almost got it.
> >  
> > Regards
> > TK 
> >  
> >
> > From: gracemckay <grace@>
> > To: DynoMotion@yahoogroups.com
> > Sent: Tuesday, October 23, 2012 9:20 AM
> > Subject: [DynoMotion] Re: Control from external switches
> >
> >  
> > Hi Tom, thanks for your patience. Here is the code I came up with based on your notes:
> >
> > #include "KMotionDef.h"
> >
> > #define PLAYBIT 16
> > #define STOPBIT 17
> > #define FASTPLAYBIT 18
> > #define REVERSEPLAYBIT 19
> > #define FASTREVERSEPLAYBIT 20
> >
> > int playlast=0,playlastsolid=-1,playcount=0;
> > int stoplast=0,stoplastsolid=-1,stopcount=0;
> > int fastplaylast=0,fastplaylastsolid=-1,fastplaycount=0;
> > int reverseplaylast=0,reverseplaylastsolid=-1,reverseplaycount=0;
> > int fastreverseplaylast=0,fastreverseplaylastsolid=-1, fastreverseplaycount=0;
> >
> > int Debounce(int n, int *cnt, int *last, int *lastsolid);
> >
> > main()
> > {
> > int play = ReadBit(PLAYBIT);
> > int stop = ReadBit (STOPBIT);
> > int fastplay = ReadBit(FASTPLAYBIT);
> > int reverseplay = ReadBit(REVERSEPLAYBIT);
> > int fastreverseplay = ReadBit(FASTREVERSEPLAYBIT);
> >
> >
> > for (;;)
> > {
> >
> > result = Debounce(play,&playcount,&playlast,&playlastsolid);
> > if (result == 1)
> > {
> > Jog(0,200);
> > }
> >
> > if (play == 1) // PLAY routine
> > {
> > Jog(0,800);
> > }
> >
> > if (stop == 1) //STOP Routine
> > {
> > Jog(0,000);
> > }
> >
> > if (fastplay == 1) //FAST PLAY Routine
> > {
> > Jog(0,1200);
> > }
> >
> > if (fastreverseplay == 1) //FAST REVERSE PLAY Routine
> > {
> > Jog(0,-1200);
> > }
> >
> > if (reverseplay == 1) //REVERSE PLAY Routine
> > {
> > Jog(0,-200);
> > }
> >
> > WaitNextTimeSlice();
> > }
> >
> > }
> >
> > // Debounce a bit
> > //
> > // return 1 one time when first debounced high
> > // return 0 one time when first debounced low
> > // return -1 otherwise
> > #define DBTIME 300
> >
> > int Debounce(int n, int *cnt, int *last, int *lastsolid)
> > {
> > int v = -1;
> >
> > if (n == *last) // same as last time?
> > {
> > if (*cnt == DBTIME-1)
> > {
> > if (n != *lastsolid)
> > {
> > v = *lastsolid = n; // return debounced value
> > }
> > }
> > if (*cnt < DBTIME) (*cnt)++;
> > }
> > else
> > {
> > *cnt = 0; // reset count
> > }
> > *last = n;
> > return v;
> > }
> >
> > This code doesn't compile, so I know I have done something wrong, but haven't figured it out yet. It stopped compiling when I dropped in the result code:
> >
> > result = Debounce(play,&playcount,&playlast,&playlastsolid);
> > if (result == 1)
> > {
> > Jog(0,200);
> > }
> >
> > Does each switch get it's own debounce code, or are the wildcards supposed to take care of it for all switches?
> >
> > Grace
> >
> > --- In mailto:DynoMotion%40yahoogroups.com, Tom Kerekes <tk@> wrote:
> > >
> > > Hi Grace,
> > >  
> > > Your program is treating IO bits as at first as inputs and then as outputs which doesn't make sense.  I assume they are really inputs.  So the code you have reading them would be correct.  Remove the code where they are set and cleared.  It isn't possible to command a pushbutton switch input to change. 
> > >  
> > > As you describe it also doesn't loop forever watching the switches.  It is also missing code that will only do something once when a switch changes rather than constantly when a switch is pushed.  It also doesn't have any switch debounce or noise filtering.
> > >  
> > > I'd like you to at least give it a try so you can learn how to make future changes.  Here is the basic process:
> > >  
> > > #1 copy in the Debounce function (see previous email).  Place it at the end of the file.  But add in the Debounce declaration towards the beginning so the compiler knows about it early on.  See how it is done in the example.
> > >  
> > > #2 a few memory variables need to be declared for each switch toward the begging of the program.  The debounce function needs these to keep track of things regarding the switch.  previous state, previous valid state, and for how long.  See the example below.  Replace the letter "f" with a letter or word that corresponds to the switch name.  Repeat for every switch.
> > >  
> > > int flast=0,flastsolid=-1,fcount=0;
> > >
> > >  
> > > so for example your "play" button might be:
> > >  
> > > int playlast=0,playlastsolid=-1,playcount=0;
> > >  
> > > #3 Then in the core of the program we can make calls to the function passing the signal of interest and the variables that it will update for that switch.  The result that it returns will tell us whether we should take action because the button was just pushed down (result==1)
> > >  
> > >  
> > >   result = Debounce(play,&playcount,&playlast,&playlastsolid);
> > >   if (result == 1)
> > >   {
> > >         Jog(0,200);
> > >   }
> > >   
> > >  
> > > #4 Add a forever loop around the core code that monitors the switches.
> > >  
> > > for (;;)
> > > {
> > >      //  put all the code that should be repeated here between the curly brackets
> > > }
> > >  
> > >  
> > > Try and see if you do those steps and post the results for us to check.  BTW your posted code doesn't have some things like FASTREVERSEPLAYHOLDBIT defined anywhere so I can't understand how it could compile.
> > >  
> > > Regards
> > > TK 
> > >  
> > >  
> > >  
> > >  
> > >  
> > >  
> > > From: gracemckay <grace@>
> > > To: mailto:DynoMotion%40yahoogroups.com
> > > Sent: Saturday, October 20, 2012 1:28 PM
> > > Subject: [DynoMotion] Re: Control from external switches
> > >
> > >  
> > > Thanks Tom, I now have the switches wired up to JP4 as you suggested. I have some code that actually kind of works. But it needs some smarts put in to it. Here is an example for the play and stop switches:
> > >
> > > #include "KMotionDef.h"
> > >
> > > #define PLAYBIT 16
> > > #define PLAYHOLDBIT 48
> > >
> > > #define STOPBIT 17
> > > #define STOPHOLDBIT 49
> > >
> > > main()
> > > {
> > >
> > > int play = ReadBit(PLAYBIT);
> > > int playhold = ReadBit(PLAYHOLDBIT);
> > > int stop = ReadBit (STOPBIT);
> > > int stophold = ReadBit (STOPHOLDBIT);
> > >
> > >
> > > if (play == 1) // PLAY routine
> > > {
> > > ClearBit(STOPHOLDBIT);
> > > ClearBit(FASTPLAYHOLDBIT);
> > > ClearBit(REVERSEPLAYHOLDBIT);
> > > ClearBit(FASTREVERSEPLAYHOLDBIT);
> > > SetBit(PLAYHOLDBIT);
> > > Jog(0,200);
> > > }
> > >
> > > if (playhold == 1) //PLAY HOLD
> > > {
> > > ClearBit(STOPHOLDBIT);
> > > ClearBit(FASTPLAYHOLDBIT);
> > > ClearBit(REVERSEPLAYHOLDBIT);
> > > ClearBit(FASTREVERSEPLAYHOLDBIT);
> > > Jog(0,200);
> > > }
> > >
> > >
> > > if (stop == 1) //STOP Routine
> > > {
> > > ClearBit(PLAYHOLDBIT);
> > > ClearBit(FASTPLAYHOLDBIT);
> > > ClearBit(REVERSEPLAYHOLDBIT);
> > > ClearBit(FASTREVERSEPLAYHOLDBIT);
> > > SetBit(STOPHOLDBIT);
> > > Jog(0,000);
> > > }
> > >
> > > if (stophold == 1) //STOP HOLD
> > > {
> > > ClearBit(PLAYHOLDBIT);
> > > ClearBit(FASTPLAYHOLDBIT);
> > > ClearBit(REVERSEPLAYHOLDBIT);
> > > ClearBit(FASTREVERSEPLAYHOLDBIT);
> > > Jog(0,000);
> > > }
> > > }
> > >
> > > There are actually 5 switches, but you get the idea. But this seems like brute force, with no elegance. And it needs a loop of some kind to keep it looking for input.
> > >
> > > Can you help fill in the details? What loop code would work and is there a better way to do this?
> > >
> > > Grace
> > >
> > > --- In mailto:DynoMotion%40yahoogroups.com, Tom Kerekes <tk@> wrote:
> > > >
> > > > Hi Grace,
> > > > ÃÆ'‚ 
> > > > There are a number of ways to wire up switches.ÃÆ'‚  One simple way is to use theÃÆ'‚ first 8 IO on KFLOP JP4 or JP6ÃÆ'‚ that have pull down resistors and simply switch the pin to +3.3V.
> > > > ÃÆ'‚ There is an example helper function called "Debounce" in Mach3_CL_PMDX.c that will help debounce your switches and tell you when the switch is first depressed (1), released (0), or no change (-1).
> > > > ÃÆ'‚ 
> > > > Regards
> > > > TK
> > > > ÃÆ'‚ 
> > > >
> > > > From: gracemckay <grace@>
> > > > To: mailto:DynoMotion%40yahoogroups.com
> > > > Sent: Friday, October 19, 2012 11:24 AM
> > > > Subject: [DynoMotion] Control from external switches
> > > >
> > > > ÃÆ'‚ 
> > > > Hi Tom,
> > > >
> > > > Me again. I am wondering if I can get my start stop rewind programs to actuate from hardware switches. These are basically jog commands on Axis 0. As and example, this is the stop routine:
> > > >
> > > > #include "KMotionDef.h"
> > > > #define FLASHBIT 0 //Bit 44 corresponds to Pin5 JP7
> > > > #define CAMERABIT 1 //Bit 45 corresponds to Pin6 JP7
> > > >
> > > > main()
> > > > {
> > > >
> > > > Jog(0,0000); // stop moving
> > > > Jog(1,0000); // stop moving
> > > > Jog(2,0000); // stop moving
> > > > Jog(3,0000); // stop moving
> > > >
> > > > SetBit(FLASHBIT); //turns led light on
> > > > SetBit(CAMERABIT); //triggers camera capture
> > > > //ClearBit(CAMERABIT); //clears camera capture
> > > > }
> > > >
> > > > The start executes a jog(0,800) the rewind is on Axis 3 jog(3,4000)
> > > >
> > > > Can these all be integrated into a single thread that listens to a set of bits that can be set with external switches? How would the switches be wired? This is how I am visualizing it, but my guess is I may be close, but that you will have a much better suggestion. What do you think?
> > > >
> > > > Grace
> > > >
> > >
> >
>
Group: DynoMotion Message: 5909 From: Tom Kerekes Date: 10/26/2012
Subject: Re: Control from external switches
Thanks for working through this on the forum Grace.  Some Users wouldn't like to learn new things in a public forum.
 
Good luck with the mechanics.
 
Regards
TK